package Sequence;

public class Test0968 {
}

class Solution0968_1 {
    int count=0;
    public int minCameraCover(TreeNode root) {
        return (dfs(root)==2?1:0)+count;
    }

    public int dfs(TreeNode root){
        if (root==null) return 0;
        int l = dfs(root.left);
        int r = dfs(root.right);
        if (l==2||r==2){
            count++;
            return 1;
        } else if (l == 1 || r == 1) {
            return 0;
        }

        return 2;
    }

}
